package td.log;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;

import com.drew.entity.Student;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.simple.SimpleLogger;

/**
 * @author zero 2019/03/24
 */
public class TestBeanUtils {
    private static final Logger log = LoggerFactory.getLogger(TestBeanUtils.class);

    static {
        System.setProperty(SimpleLogger.WARN_LEVEL_STRING_KEY, "TRACE");

    }
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
        Student student = new Student(1, "Drew");
        Student student2 = (Student) BeanUtils.cloneBean(student);
        log.warn("student{}", student);
        log.warn("student2{}", student2);
        Student student3 = new Student();
        BeanUtils.copyProperties(student3, student);// 第一个参数是：目标存储，第二个参数：源数据
        log.info("student3{}", student3);
    }

}